<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>垫款批次表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">发送时间</div>
                    <div class="field">
                        <input ligerui="width: 85" name="crtTmMin" id="crtTmMin" type="text" class="ui-datepicker"
                               value="">
                        -
                        <input ligerui="width: 85" name="crtTmMax" id="crtTmMax" type="text" class="ui-datepicker"
                               value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">规则名称</div>
                    <div class="field">
                        <input name="ruleNm" id="ruleNm" type="text" class="ui-textbox" value="" validate="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">垫款金额</div>
                    <div class="field">
                        <input ligerui="width: 82" name="minAdvAmt" id="minAdvAmt" type="text" class="ui-textbox"
                               value="" validate="{number:true}">
                        -
                        <input ligerui="width: 82" name="maxAdvAmt" id="maxAdvAmt" type="text" class="ui-textbox"
                               value="" validate="{number:true}">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">指令类型</div>
                    <div class="field">
                        <input name="advWayCd" id="advWayCd" placeholder="请选择" ltype="combobox">
                    </div>
                    <input type="text" name="advTypCd" id="advTypCd" value="${advTypCd}" style="display: none;">
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <span id="addBtn" class="sq-button sq-button-round">手动添加指令</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/capital/capAdvBatch/initList.do',
            method: 'get',
            columns: [
                {display: '批次编号', name: 'id', minWidth: 100, align: 'left',},
		        {display: '发送时间', name: 'advRuleId', minWidth: 100, align: 'center',render:renderDate},
		        {display: '规则名称', name: 'ruleNm', minWidth: 100, align: 'left', },
                {display: '逾期金额', name: 'ovdAmounts', minWidth: 100, align: 'center'},
                {display: '逾期天数', name: 'ovdDays', minWidth: 100, align: 'center', },
                {display: '垫款金额', name: 'advTtlAmt', minWidth: 100, align: 'right',
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.advTtlAmt / 100);
                    }
                },
                {display: '指令类型', name: 'advWayCdNm', minWidth: 100, align: 'center', },
                {
                    display: '操作',minWidth: 80, align: 'left', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '<a style="cursor: pointer;" onclick="advRvtDtl(' + rowdata.id + ');">详情</a>';
                    }
                },
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);

        //指令类型
        $("#advWayCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#searchBar").ligerForm();
        liger.get("advWayCd").setData(${advWayCdList});

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        callback = function () {
            grid.reload();
        };

        /* 手动添加指令 */
        $("#addBtn").click(function (event) {
            $.ligerDialog.open({
                width: 550,
                height: 500,
                title: '手动添加垫款批次',
                url:'<%=path%>/capital/capAdvBatch/toAddPage.do'
            });
            //Add_navTab("CapAdvBatch_1", "新增垫款批次表", '<%=path%>/capital/capAdvBatch/toAddPage.do', callback);
        });

    });

    function advRvtDtl(id) {
        Add_navTab("CapAdvBatch_"+id, "垫款详情", '<%=path%>/capital/capAdvBatch/toDtlPage.do?advTypCd=${advTypCd}&id='+id, callback);
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
</script>

</body>
</html>
